#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<string.h>

int main()
{
    int n = 0;
    scanf("%d", &n);
    int i = 0;
    for (i = 0; i < n; i++)
    {
        char arr[101] = { 0 };
        scanf("%s", arr);
        int j = 0;
        int lower = 0, digit = 0, higher = 0, other = 0;
        if (arr[0] >= '0' && arr[0] <= '9')\
        {
            printf("NO\n");
            continue;
        }
        if (strlen(arr) < 8)
        {
            printf("NO\n");
            continue;
        }
        for (j = 0; arr[j] != '\0'; j++)
        {
            if (arr[j] >= '0' && arr[j] <= '9')
            {
                digit++;
            }
            else if (arr[j] >= 'a' && arr[j] <= 'z')
            {
                lower++;
            }
            else if (arr[j] >= 'A' && arr[j] <= 'Z')
            {
                higher++;
            }
            else
            {
                other++;
            }
        }
        if (other != 0)
        {
            printf("NO\n");
            continue;
        }
        if ((digit > 0) + (lower > 0) + (higher > 0) < 2)
        {
            printf("NO\n");
            continue;
        }
        printf("YES\n");
    }
    return 0;
}